<?php
namespace Interf\Controller;

use Think\Controller;


class  PageController extends Controller
{
    public function _initialize()
    {
        header("Access-Control-Allow-Origin:*");
    }

//    根据姓名性别等关键字，查出它所有的字段；
    public function index()
    {
        if (IS_POST) {
            $thisyear=Date('Y');

            $sno=I('sno');

            $infom=array();
            $db = M("baseinfo_interf");
            $infom = $db->where("xh = '$sno'")->find();

            $infom['birth']=substr($infom['birth'],0,10);

            $birthyear=$infom['birth'];
            $age=$thisyear-$birthyear;
            $infom['age']=$age;

            $value = substr($sno, 0, 4);
            if (file_exists($_SERVER['DOCUMENT_ROOT']. '/'.'jw'.C('PHOTO_PATH') . '/' . $value . '/' . $sno . '.jpg')) {
                $photo = C('PHOTO_PATH') . '/' . $value . '/' . $sno . '.jpg';
            }else{
                $photo = "/public/img/default.jpg";
            }
            $photo='http://192.168.1.66'.__ROOT__.$photo;

            $infom['photo']=$photo;

            echo json_encode(array("status" => "ok", "inform" => $infom,'info' => '成功'), JSON_UNESCAPED_UNICODE);
        }else{
            echo json_encode(array("status" => "ok", "inform" => '', 'info' => '未用post方法提交'), JSON_UNESCAPED_UNICODE);
        }

    }
}